﻿using Hidistro.Entities.Sales;
using Hidistro.UI.Common.Controls;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class wnxd_PromotionsColumn : AscxTemplatedWebControl
    {
        protected Repeater Rname;
        public wnxd_PromotionsColumn()
        {
            base.ID = "wnxd_PromotionsColumn";
        }
        protected override void AttachChildControls()
        {
            Dictionary<string, List<ShoppingCartItemInfo>> list = ((Common_ShoppingCart_ProductList)(this.Parent.Parent.Parent.Parent.Parent)).promotions;
            this.Rname = (Repeater)this.FindControl("Rname");
            this.Rname.ItemDataBound += Rname_ItemDataBound;
            this.Rname.DataSource = list;
            this.Rname.DataBind();
        }

        void Rname_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater Rlist = (Repeater)e.Item.FindControl("Rlist");
                KeyValuePair<string, List<ShoppingCartItemInfo>> kv = (KeyValuePair<string, List<ShoppingCartItemInfo>>)e.Item.DataItem;
                Rlist.DataSource = kv.Value;
                Rlist.DataBind();
            }
        }
        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "/ascx/tags/Common_ShoppingCart/wnxd-PromotionsColumn.ascx";
            }
            base.OnInit(e);
        }
        public override string ID
        {
            get
            {
                return base.ID;
            }
            set
            {
                base.ID = value;
            }
        }
    }
}
